package com.zyl.service.Impl;

import com.zyl.Mapper.PrivateWordMapper;
import com.zyl.pojo.PrivateWord;
import com.zyl.service.PrivateWordService;
import com.zyl.vo.PrivateWordVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

/**
 * @Author: Zyl
 * @Param:
 * @return:
 * @Description:
 */
@Service
public class PrivateWordImpl  implements PrivateWordService {
    @Autowired
    private PrivateWordMapper privateWordMapper;
    @Override
    public List<PrivateWord> findAll() {
        return privateWordMapper.findAll();
    }

    @Override
    public PrivateWord findPrivateWordById(Integer id) {

        PrivateWord privateById = privateWordMapper.findPrivateById(id);
        return privateById;
    }

    @Override
    public void responsePrivateWord(PrivateWord privateWord) {
        privateWordMapper.responsePrivateWord(privateWord);
    }

    @Override
    public void addPrivateWord(PrivateWord privateWord) {
        Date d = new Date();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        privateWord.setPublisherDate(sdf.format(d));
        privateWordMapper.addPrivateWord(privateWord);
    }

    @Override
    public List<PrivateWordVo> findPrivateWordByPublishId(Integer id) {
        List<PrivateWordVo> privateWordByPublishId = privateWordMapper.findPrivateWordByPublishId(id);
        return privateWordByPublishId;
    }

    @Override
    public Integer privateWordCount() {
        return privateWordMapper.privateWordCount();
    }

}
